package com.cloud.yangfeiself.aspect;


import com.cloud.yangfeiself.dto.ResResult;
import com.cloud.yangfeiself.util.WebUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * controller异常切面处理
 *
 * @author Yang Fei
 * @dat021/3/12
 */
@ControllerAdvice
@Slf4j
public class ControllerExceptionHandler {


    private static final String EXCEPTION_MSG = "服务器繁忙";


    @ExceptionHandler(Exception.class)
    public void handlerException(Exception ex) {
        log.error(ex.getMessage(),ex);
        WebUtil.responseJson(ResResult.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), EXCEPTION_MSG));
    }

}
